3.5.39 \(\int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx\) [439]

3.5.39.1 Optimal result
3.5.39.2 Mathematica [A] (verified)
3.5.39.3 Rubi [A] (verified)
3.5.39.4 Maple [A] (verified)
3.5.39.5 Fricas [A] (verification not implemented)
3.5.39.6 Sympy [B] (verification not implemented)
3.5.39.7 Maxima [F(-2)]
3.5.39.8 Giac [A] (verification not implemented)
3.5.39.9 Mupad [B] (verification not implemented)

3.5.39.1 Optimal result

Integrand size = 25, antiderivative size = 83 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=-\frac {9 (c-2 d) x}{d^2}+\frac {18 (c-d)^2 \arctan \left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{d^2 \sqrt {c^2-d^2} f}-\frac {9 \cos (e+f x)}{d f} \]

output
-a^2*(c-2*d)*x/d^2-a^2*cos(f*x+e)/d/f+2*a^2*(c-d)^2*arctan((d+c*tan(1/2*f* 
x+1/2*e))/(c^2-d^2)^(1/2))/d^2/f/(c^2-d^2)^(1/2)
 
3.5.39.2 Mathematica [A] (verified)

Time = 0.15 (sec) , antiderivative size = 79, normalized size of antiderivative = 0.95 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=-\frac {9 \left ((c-2 d) (e+f x)-\frac {2 (c-d)^2 \arctan \left (\frac {d+c \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c^2-d^2}}\right )}{\sqrt {c^2-d^2}}+d \cos (e+f x)\right )}{d^2 f} \]

input
Integrate[(3 + 3*Sin[e + f*x])^2/(c + d*Sin[e + f*x]),x]
 
output
(-9*((c - 2*d)*(e + f*x) - (2*(c - d)^2*ArcTan[(d + c*Tan[(e + f*x)/2])/Sq 
rt[c^2 - d^2]])/Sqrt[c^2 - d^2] + d*Cos[e + f*x]))/(d^2*f)
 
3.5.39.3 Rubi [A] (verified)

Time = 0.48 (sec) , antiderivative size = 103, normalized size of antiderivative = 1.24, number of steps used = 9, number of rules used = 8, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.320, Rules used = {3042, 3225, 3042, 3214, 3042, 3139, 1083, 217}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {(a \sin (e+f x)+a)^2}{c+d \sin (e+f x)} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(a \sin (e+f x)+a)^2}{c+d \sin (e+f x)}dx\)

\(\Big \downarrow \) 3225

\(\displaystyle \frac {\int \frac {a^2 d-a^2 (c-2 d) \sin (e+f x)}{c+d \sin (e+f x)}dx}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {a^2 d-a^2 (c-2 d) \sin (e+f x)}{c+d \sin (e+f x)}dx}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 3214

\(\displaystyle \frac {\frac {a^2 (c-d)^2 \int \frac {1}{c+d \sin (e+f x)}dx}{d}-\frac {a^2 x (c-2 d)}{d}}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {a^2 (c-d)^2 \int \frac {1}{c+d \sin (e+f x)}dx}{d}-\frac {a^2 x (c-2 d)}{d}}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 3139

\(\displaystyle \frac {\frac {2 a^2 (c-d)^2 \int \frac {1}{c \tan ^2\left (\frac {1}{2} (e+f x)\right )+2 d \tan \left (\frac {1}{2} (e+f x)\right )+c}d\tan \left (\frac {1}{2} (e+f x)\right )}{d f}-\frac {a^2 x (c-2 d)}{d}}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 1083

\(\displaystyle \frac {-\frac {4 a^2 (c-d)^2 \int \frac {1}{-\left (2 d+2 c \tan \left (\frac {1}{2} (e+f x)\right )\right )^2-4 \left (c^2-d^2\right )}d\left (2 d+2 c \tan \left (\frac {1}{2} (e+f x)\right )\right )}{d f}-\frac {a^2 x (c-2 d)}{d}}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

\(\Big \downarrow \) 217

\(\displaystyle \frac {\frac {2 a^2 (c-d)^2 \arctan \left (\frac {2 c \tan \left (\frac {1}{2} (e+f x)\right )+2 d}{2 \sqrt {c^2-d^2}}\right )}{d f \sqrt {c^2-d^2}}-\frac {a^2 x (c-2 d)}{d}}{d}-\frac {a^2 \cos (e+f x)}{d f}\)

input
Int[(a + a*Sin[e + f*x])^2/(c + d*Sin[e + f*x]),x]
 
output
(-((a^2*(c - 2*d)*x)/d) + (2*a^2*(c - d)^2*ArcTan[(2*d + 2*c*Tan[(e + f*x) 
/2])/(2*Sqrt[c^2 - d^2])])/(d*Sqrt[c^2 - d^2]*f))/d - (a^2*Cos[e + f*x])/( 
d*f)
 

3.5.39.3.1 Defintions of rubi rules used

rule 217
Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(-(Rt[-a, 2]*Rt[-b, 2])^( 
-1))*ArcTan[Rt[-b, 2]*(x/Rt[-a, 2])], x] /; FreeQ[{a, b}, x] && PosQ[a/b] & 
& (LtQ[a, 0] || LtQ[b, 0])
 

rule 1083
Int[((a_) + (b_.)*(x_) + (c_.)*(x_)^2)^(-1), x_Symbol] :> Simp[-2   Subst[I 
nt[1/Simp[b^2 - 4*a*c - x^2, x], x], x, b + 2*c*x], x] /; FreeQ[{a, b, c}, 
x]
 

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 3139
Int[((a_) + (b_.)*sin[(c_.) + (d_.)*(x_)])^(-1), x_Symbol] :> With[{e = Fre 
eFactors[Tan[(c + d*x)/2], x]}, Simp[2*(e/d)   Subst[Int[1/(a + 2*b*e*x + a 
*e^2*x^2), x], x, Tan[(c + d*x)/2]/e], x]] /; FreeQ[{a, b, c, d}, x] && NeQ 
[a^2 - b^2, 0]
 

rule 3214
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])/((c_.) + (d_.)*sin[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[b*(x/d), x] - Simp[(b*c - a*d)/d   Int[1/(c + d 
*Sin[e + f*x]), x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0]
 

rule 3225
Int[((a_.) + (b_.)*sin[(e_.) + (f_.)*(x_)])^2/((c_.) + (d_.)*sin[(e_.) + (f 
_.)*(x_)]), x_Symbol] :> Simp[(-b^2)*(Cos[e + f*x]/(d*f)), x] + Simp[1/d 
Int[Simp[a^2*d - b*(b*c - 2*a*d)*Sin[e + f*x], x]/(c + d*Sin[e + f*x]), x], 
 x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0]
 
3.5.39.4 Maple [A] (verified)

Time = 0.85 (sec) , antiderivative size = 105, normalized size of antiderivative = 1.27

method result size
derivativedivides \(\frac {2 a^{2} \left (-\frac {\frac {d}{1+\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )}+\left (c -2 d \right ) \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d^{2}}+\frac {\left (c^{2}-2 c d +d^{2}\right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d^{2} \sqrt {c^{2}-d^{2}}}\right )}{f}\) \(105\)
default \(\frac {2 a^{2} \left (-\frac {\frac {d}{1+\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )}+\left (c -2 d \right ) \arctan \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )\right )}{d^{2}}+\frac {\left (c^{2}-2 c d +d^{2}\right ) \arctan \left (\frac {2 c \tan \left (\frac {f x}{2}+\frac {e}{2}\right )+2 d}{2 \sqrt {c^{2}-d^{2}}}\right )}{d^{2} \sqrt {c^{2}-d^{2}}}\right )}{f}\) \(105\)
risch \(-\frac {a^{2} x c}{d^{2}}+\frac {2 a^{2} x}{d}-\frac {a^{2} {\mathrm e}^{i \left (f x +e \right )}}{2 d f}-\frac {a^{2} {\mathrm e}^{-i \left (f x +e \right )}}{2 d f}+\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right ) c}{\left (c +d \right ) f \,d^{2}}-\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right )}{\left (c +d \right ) f d}-\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {-i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right ) c}{\left (c +d \right ) f \,d^{2}}+\frac {\sqrt {-\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {-i c +\sqrt {-\left (c +d \right ) \left (c -d \right )}}{d}\right )}{\left (c +d \right ) f d}\) \(303\)

input
int((a+a*sin(f*x+e))^2/(c+d*sin(f*x+e)),x,method=_RETURNVERBOSE)
 
output
2/f*a^2*(-1/d^2*(d/(1+tan(1/2*f*x+1/2*e)^2)+(c-2*d)*arctan(tan(1/2*f*x+1/2 
*e)))+(c^2-2*c*d+d^2)/d^2/(c^2-d^2)^(1/2)*arctan(1/2*(2*c*tan(1/2*f*x+1/2* 
e)+2*d)/(c^2-d^2)^(1/2)))
 
3.5.39.5 Fricas [A] (verification not implemented)

Time = 0.30 (sec) , antiderivative size = 296, normalized size of antiderivative = 3.57 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=\left [-\frac {2 \, a^{2} d \cos \left (f x + e\right ) + 2 \, {\left (a^{2} c - 2 \, a^{2} d\right )} f x + {\left (a^{2} c - a^{2} d\right )} \sqrt {-\frac {c - d}{c + d}} \log \left (\frac {{\left (2 \, c^{2} - d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2} + 2 \, {\left ({\left (c^{2} + c d\right )} \cos \left (f x + e\right ) \sin \left (f x + e\right ) + {\left (c d + d^{2}\right )} \cos \left (f x + e\right )\right )} \sqrt {-\frac {c - d}{c + d}}}{d^{2} \cos \left (f x + e\right )^{2} - 2 \, c d \sin \left (f x + e\right ) - c^{2} - d^{2}}\right )}{2 \, d^{2} f}, -\frac {a^{2} d \cos \left (f x + e\right ) + {\left (a^{2} c - 2 \, a^{2} d\right )} f x + {\left (a^{2} c - a^{2} d\right )} \sqrt {\frac {c - d}{c + d}} \arctan \left (-\frac {{\left (c \sin \left (f x + e\right ) + d\right )} \sqrt {\frac {c - d}{c + d}}}{{\left (c - d\right )} \cos \left (f x + e\right )}\right )}{d^{2} f}\right ] \]

input
integrate((a+a*sin(f*x+e))^2/(c+d*sin(f*x+e)),x, algorithm="fricas")
 
output
[-1/2*(2*a^2*d*cos(f*x + e) + 2*(a^2*c - 2*a^2*d)*f*x + (a^2*c - a^2*d)*sq 
rt(-(c - d)/(c + d))*log(((2*c^2 - d^2)*cos(f*x + e)^2 - 2*c*d*sin(f*x + e 
) - c^2 - d^2 + 2*((c^2 + c*d)*cos(f*x + e)*sin(f*x + e) + (c*d + d^2)*cos 
(f*x + e))*sqrt(-(c - d)/(c + d)))/(d^2*cos(f*x + e)^2 - 2*c*d*sin(f*x + e 
) - c^2 - d^2)))/(d^2*f), -(a^2*d*cos(f*x + e) + (a^2*c - 2*a^2*d)*f*x + ( 
a^2*c - a^2*d)*sqrt((c - d)/(c + d))*arctan(-(c*sin(f*x + e) + d)*sqrt((c 
- d)/(c + d))/((c - d)*cos(f*x + e))))/(d^2*f)]
 
3.5.39.6 Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 3709 vs. \(2 (76) = 152\).

Time = 124.12 (sec) , antiderivative size = 3709, normalized size of antiderivative = 44.69 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=\text {Too large to display} \]

input
integrate((a+a*sin(f*x+e))**2/(c+d*sin(f*x+e)),x)
 
output
Piecewise((zoo*x*(a*sin(e) + a)**2/sin(e), Eq(c, 0) & Eq(d, 0) & Eq(f, 0)) 
, ((2*a**2*f*x*tan(e/2 + f*x/2)**2/(f*tan(e/2 + f*x/2)**2 + f) + 2*a**2*f* 
x/(f*tan(e/2 + f*x/2)**2 + f) + a**2*log(tan(e/2 + f*x/2))*tan(e/2 + f*x/2 
)**2/(f*tan(e/2 + f*x/2)**2 + f) + a**2*log(tan(e/2 + f*x/2))/(f*tan(e/2 + 
 f*x/2)**2 + f) - 2*a**2/(f*tan(e/2 + f*x/2)**2 + f))/d, Eq(c, 0)), (2*a** 
2*d**2*f*x*tan(e/2 + f*x/2)**3/(d**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/ 
2 + f*x/2) - f*(d**2)**(3/2)*tan(e/2 + f*x/2)**2 - f*(d**2)**(3/2)) - a**2 
*d**2*f*x*tan(e/2 + f*x/2)**2/(d**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/2 
 + f*x/2) - f*(d**2)**(3/2)*tan(e/2 + f*x/2)**2 - f*(d**2)**(3/2)) + 2*a** 
2*d**2*f*x*tan(e/2 + f*x/2)/(d**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/2 + 
 f*x/2) - f*(d**2)**(3/2)*tan(e/2 + f*x/2)**2 - f*(d**2)**(3/2)) - a**2*d* 
*2*f*x/(d**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/2 + f*x/2) - f*(d**2)**( 
3/2)*tan(e/2 + f*x/2)**2 - f*(d**2)**(3/2)) + 4*a**2*d**2*tan(e/2 + f*x/2) 
**2/(d**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/2 + f*x/2) - f*(d**2)**(3/2 
)*tan(e/2 + f*x/2)**2 - f*(d**2)**(3/2)) - 2*a**2*d**2*tan(e/2 + f*x/2)/(d 
**3*f*tan(e/2 + f*x/2)**3 + d**3*f*tan(e/2 + f*x/2) - f*(d**2)**(3/2)*tan( 
e/2 + f*x/2)**2 - f*(d**2)**(3/2)) + 4*a**2*d**2/(d**3*f*tan(e/2 + f*x/2)* 
*3 + d**3*f*tan(e/2 + f*x/2) - f*(d**2)**(3/2)*tan(e/2 + f*x/2)**2 - f*(d* 
*2)**(3/2)) + a**2*d*f*x*sqrt(d**2)*tan(e/2 + f*x/2)**3/(d**3*f*tan(e/2 + 
f*x/2)**3 + d**3*f*tan(e/2 + f*x/2) - f*(d**2)**(3/2)*tan(e/2 + f*x/2)*...
 
3.5.39.7 Maxima [F(-2)]

Exception generated. \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=\text {Exception raised: ValueError} \]

input
integrate((a+a*sin(f*x+e))^2/(c+d*sin(f*x+e)),x, algorithm="maxima")
 
output
Exception raised: ValueError >> Computation failed since Maxima requested 
additional constraints; using the 'assume' command before evaluation *may* 
 help (example of legal syntax is 'assume(4*d^2-4*c^2>0)', see `assume?` f 
or more de
 
3.5.39.8 Giac [A] (verification not implemented)

Time = 0.42 (sec) , antiderivative size = 132, normalized size of antiderivative = 1.59 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=-\frac {\frac {{\left (a^{2} c - 2 \, a^{2} d\right )} {\left (f x + e\right )}}{d^{2}} + \frac {2 \, a^{2}}{{\left (\tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} + 1\right )} d} - \frac {2 \, {\left (a^{2} c^{2} - 2 \, a^{2} c d + a^{2} d^{2}\right )} {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (c\right ) + \arctan \left (\frac {c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + d}{\sqrt {c^{2} - d^{2}}}\right )\right )}}{\sqrt {c^{2} - d^{2}} d^{2}}}{f} \]

input
integrate((a+a*sin(f*x+e))^2/(c+d*sin(f*x+e)),x, algorithm="giac")
 
output
-((a^2*c - 2*a^2*d)*(f*x + e)/d^2 + 2*a^2/((tan(1/2*f*x + 1/2*e)^2 + 1)*d) 
 - 2*(a^2*c^2 - 2*a^2*c*d + a^2*d^2)*(pi*floor(1/2*(f*x + e)/pi + 1/2)*sgn 
(c) + arctan((c*tan(1/2*f*x + 1/2*e) + d)/sqrt(c^2 - d^2)))/(sqrt(c^2 - d^ 
2)*d^2))/f
 
3.5.39.9 Mupad [B] (verification not implemented)

Time = 8.21 (sec) , antiderivative size = 940, normalized size of antiderivative = 11.33 \[ \int \frac {(3+3 \sin (e+f x))^2}{c+d \sin (e+f x)} \, dx=\frac {4\,a^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{f\,\left (c+d\right )}-\frac {a^2\,\cos \left (e+f\,x\right )}{f\,\left (c+d\right )}+\frac {2\,a^2\,c\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{d\,f\,\left (c+d\right )}-\frac {2\,a^2\,c^2\,\mathrm {atan}\left (\frac {\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )}{\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )}\right )}{d^2\,f\,\left (c+d\right )}-\frac {a^2\,c\,\cos \left (e+f\,x\right )}{d\,f\,\left (c+d\right )}+\frac {a^2\,\mathrm {atan}\left (\frac {\left (3\,d^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (-c^4+2\,c^3\,d-2\,c\,d^3+d^4\right )}^{3/2}-2\,c^6\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}-2\,c^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (-c^4+2\,c^3\,d-2\,c\,d^3+d^4\right )}^{3/2}+7\,d^6\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+10\,c\,d^5\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+4\,c^5\,d\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+4\,c^2\,d^4\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}-3\,c^3\,d^3\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}-2\,c^4\,d^2\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}-9\,c^2\,d^4\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}-12\,c^3\,d^3\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+6\,c^4\,d^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+c\,d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,{\left (-c^4+2\,c^3\,d-2\,c\,d^3+d^4\right )}^{3/2}+4\,c\,d^5\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}+c^5\,d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )\,\sqrt {-c^4+2\,c^3\,d-2\,c\,d^3+d^4}\right )\,1{}\mathrm {i}}{d\,\left (c+d\right )\,\left (3\,c^5\,d\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )-5\,c\,d^5\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )-10\,d^6\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )+16\,c\,d^5\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )+8\,c^2\,d^4\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+2\,c^3\,d^3\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )-8\,c^4\,d^2\,\cos \left (\frac {e}{2}+\frac {f\,x}{2}\right )+4\,c^2\,d^4\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )-16\,c^3\,d^3\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )+6\,c^4\,d^2\,\sin \left (\frac {e}{2}+\frac {f\,x}{2}\right )\right )}\right )\,\sqrt {-\left (c+d\right )\,{\left (c-d\right )}^3}\,2{}\mathrm {i}}{d^2\,f\,\left (c+d\right )} \]

input
int((a + a*sin(e + f*x))^2/(c + d*sin(e + f*x)),x)
 
output
(4*a^2*atan(sin(e/2 + (f*x)/2)/cos(e/2 + (f*x)/2)))/(f*(c + d)) - (a^2*cos 
(e + f*x))/(f*(c + d)) + (2*a^2*c*atan(sin(e/2 + (f*x)/2)/cos(e/2 + (f*x)/ 
2)))/(d*f*(c + d)) - (2*a^2*c^2*atan(sin(e/2 + (f*x)/2)/cos(e/2 + (f*x)/2) 
))/(d^2*f*(c + d)) + (a^2*atan(((3*d^2*sin(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d 
^3 - c^4 + d^4)^(3/2) - 2*c^6*sin(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 
+ d^4)^(1/2) - 2*c^2*sin(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(3 
/2) + 7*d^6*sin(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) + 10* 
c*d^5*sin(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) + 4*c^5*d*s 
in(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) + 4*c^2*d^4*cos(e/ 
2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) - 3*c^3*d^3*cos(e/2 + ( 
f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) - 2*c^4*d^2*cos(e/2 + (f*x)/ 
2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) - 9*c^2*d^4*sin(e/2 + (f*x)/2)*(2 
*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2) - 12*c^3*d^3*sin(e/2 + (f*x)/2)*(2*c^3 
*d - 2*c*d^3 - c^4 + d^4)^(1/2) + 6*c^4*d^2*sin(e/2 + (f*x)/2)*(2*c^3*d - 
2*c*d^3 - c^4 + d^4)^(1/2) + c*d*cos(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c 
^4 + d^4)^(3/2) + 4*c*d^5*cos(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^ 
4)^(1/2) + c^5*d*cos(e/2 + (f*x)/2)*(2*c^3*d - 2*c*d^3 - c^4 + d^4)^(1/2)) 
*1i)/(d*(c + d)*(3*c^5*d*cos(e/2 + (f*x)/2) - 5*c*d^5*cos(e/2 + (f*x)/2) - 
 10*d^6*sin(e/2 + (f*x)/2) + 16*c*d^5*sin(e/2 + (f*x)/2) + 8*c^2*d^4*cos(e 
/2 + (f*x)/2) + 2*c^3*d^3*cos(e/2 + (f*x)/2) - 8*c^4*d^2*cos(e/2 + (f*x...